package com.shenhao.hpfa.init;

import com.shenhao.hpfa.model.DeviceInfo;
import com.shenhao.hpfa.model.Payload;
import com.shenhao.hpfa.service.HpfaDeviceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.concurrent.TimeUnit;

@Slf4j
@Component
public class InitRunner implements CommandLineRunner {

    @Resource
    private HpfaDeviceService hpfaDeviceService;

    @Override
    public void run(String... args) throws Exception {
        hpfaDeviceService.switchOffAll();
//        log.info("查询状态");
//        Payload<DeviceInfo> payload1 = hpfaDeviceService.queryStatus("JE14300114");
//        log.info("payload1:{}", payload1);
//        TimeUnit.SECONDS.sleep(1);
//        log.info("打开开关");
//        Payload<DeviceInfo> payload2 = hpfaDeviceService.switchOn("JE14300114");
//        log.info("payload2:{}", payload2);
//        TimeUnit.SECONDS.sleep(1);
//        log.info("关闭开关");
//        Payload<DeviceInfo> payload3 =hpfaDeviceService.switchOn("JE14300114");
//        log.info("payload3:{}", payload3);
    }
}
